package com.zhsm.fuxi.mvp.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zhsm.fuxi.R
import com.zhsm.fuxi.bean.OrderInfo
import com.zhsm.fuxi.utils.TimeUtils


/**
 * Created by GuZhC on 2018/11/7.
 * describe:
 */
class InvoiceRecyclerAdapter(data: List<OrderInfo>) : BaseQuickAdapter<OrderInfo, BaseViewHolder>(R.layout.layout_order_invoice, data) {
    override fun convert(helper: BaseViewHolder, data: OrderInfo) {

        val startTime = TimeUtils.getTime(data.createTime!!, TimeUtils.DATE_SIMPLE_DATA)
        var endTime = ""
        if (data.checked!!) helper.setChecked(R.id.invoiceCb, true)
        else helper.setChecked(R.id.invoiceCb, false)
        helper.setText(R.id.invoiceState, "¥${data.amount}")
        data.updateTime?.let {
            if (data.updateTime > 0)
                endTime = "—${TimeUtils.getTime(it, TimeUtils.DATE_SIMPLE_DATA)}"
        }
        helper.setText(R.id.invoiceTime, startTime + endTime)
        helper.setText(R.id.invoiceStart, data.takeStation)
        if (!data.returnStation.isNullOrBlank())
            helper.setText(R.id.invoiceEnd, data.returnStation)
        else helper.setGone(R.id.invoiceEnd, false)
        helper.addOnClickListener(R.id.invoiceCb)
    }
}